<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户注册</title>
<script type="text/javascript">
    var path = window.document.location.href;
	var pathName = window.document.location.pathname;
	var hostPath = path.substring(0, path.indexOf(pathName));
	var projectName = pathName.substring(0, pathName.substr(1).indexOf("/") + 1);
	document.write('<scr' + 'ipt src="' + projectName + '/js/html/header.js"></scr'+'ipt>');
</script>
</head>
<body>
	<form action="#" id="registerForm" class="fh5co-form">
		<div style="width: 500px; height: 400px; position: fixed; left: 50%; top: 50%; z-index: 11; margin: -200px 0 0 -250px;">
			<table align="left" boder="1" cellspacing="10">
				<tr align="center">
					<td align="right">登录用户名：</td>
					<td align="left"><input type="text" id="loginName" name="loginName"></td>
				</tr>
				<tr align="center">
					<td align="right">用户密码：</td>
					<td align="left"><input type="password" id="passWord" name="passWord"></td>
				</tr>
				<tr align="center">
					<td align="right">用户姓名：</td>
					<td align="left"><input type="text" id="userName" name="userName"></td>
				</tr>
				<tr align="center">
					<td align="right">用户工号：</td>
					<td align="left"><input type="text" id="empNo" name="empNo"></td>
				</tr>
				<tr align="center">
					<td align="right">邮箱：</td>
					<td align="left"><input type="text" id="email" name="email"></td>
				</tr>
				<tr align="center">
					<td><a href="javascript:submitRegister()" class="easyui-linkbutton" iconCls="icon-ok">注册</a></td>
					<td><a href="javascript:console()" class="easyui-linkbutton" iconCls="icon-undo">重置</a>
				</tr>
			</table>
		</div>
	</form>
	<script>
		function console(){
			$("#loginName").attr("value","");
			$("#passWord").attr("value","");
			$("#userName").attr("value","");
			$("#empNo").attr("value","");
			$("#email").attr("value","");
		}
		
		function submitRegister() {
			var loginName  = $("#loginName").val();
			
			if(loginName=="" || loginName=="" || loginName==""){
				$.messager.alert('警告','请输入登录用户名！');
			}else{
				$.messager.progress();
				$.ajax({
					type : "POST",
					url : projectName+"/index/register",						
					data: JSON.stringify($("#registerForm").serializeObject()),
					dataType : "json",
					contentType : "application/json;charset=utf-8",
					success : function(data) {
						$.messager.progress("close");
						if (!data.success) {
							alert(data.message);
							return;
						}
						if (data != null) {
							$.messager.alert('提示','注册成功！');
							console();
						}
					},
					error:function(err, status){
						$.messager.progress("close");
						errorMsgAlert(err);
					}
				});
			}
		}

	</script>
</body>
</html>